From 8f7262f9a6fa915e25becde39a9e10607702b31d Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 15 Jul 2005 08:30:22 +0000 Subject: [PATCH] Recently some people complain that they cannot set the maxmem for domU. The problem is that some code wrongly treat dom.max_memkb as in byte unit, instead of KB unit. This patch fixs the problem. Signed-off-by: Nguyen Anh Quynh --- tools/libxc/xc_domain.c | 2 +- tools/libxc/xc_linux_save.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index a341bb0bc3..688dbb970a 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -107,7 +107,7 @@ int xc_domain_getinfo(int xc_handle, info->ssidref = op.u.getdomaininfo.ssidref; info->nr_pages = op.u.getdomaininfo.tot_pages; - info->max_memkb = op.u.getdomaininfo.max_pages<<(PAGE_SHIFT); + info->max_memkb = op.u.getdomaininfo.max_pages << (PAGE_SHIFT - 10); info->shared_info_frame = op.u.getdomaininfo.shared_info_frame; info->cpu_time = op.u.getdomaininfo.cpu_time; info->vcpus = op.u.getdomaininfo.n_vcpu; diff --git a/tools/libxc/xc_linux_save.c b/tools/libxc/xc_linux_save.c index f761141170..023a59c799 100644 --- a/tools/libxc/xc_linux_save.c +++ b/tools/libxc/xc_linux_save.c @@ -464,15 +464,15 @@ int xc_linux_save(int xc_handle, int io_fd, u32 dom) goto out; } - nr_pfns = info.max_memkb >> PAGE_SHIFT; + nr_pfns = info.max_memkb >> (PAGE_SHIFT - 10); /* cheesy sanity check */ - if ( nr_pfns > 1024*1024 ){ + if ( nr_pfns > 1024*1024 ) + { ERR("Invalid state record -- pfn count out of range: %lu", nr_pfns); goto out; } - /* Map the shared info frame */ live_shinfo = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ, -- 2.30.2